package com.ddone.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ddone
 * @date 2024/4/5-14:10
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/pay/{orderId}")
    public String pay(@PathVariable("orderId") String orderId){
        System.out.println("订单: "+orderId+" 支付完成, 更新订单状态为已支付.");

        // 发送消息到MQ

        rabbitTemplate.convertAndSend("order.exchange","order.pay","您好啊~~~");
        return "success";

    }

}
